#include "firstmain.h"



WebCateList::WebCateList( QWidget* parent )
	: QTreeView( parent )
{
	Small_Language = config_language_short();
  Long_Language =  config_language_long();
}

void WebCateList::SetDb( DB_Manager * dbin )
{
	db = dbin;
	c_model = new QSqlQueryModel();
  //////init();
	qDebug() << "### init go WebCateList  ";
	connect(this, SIGNAL(doubleClicked(QModelIndex) ), this , SLOT(ActiveTre(QModelIndex) ));
}

void WebCateList::contextMenuEvent ( QContextMenuEvent * e )
{
	QModelIndex ain = currentIndex();
	uint oggettoID = 0;
	QFileIconProvider  sysicon;


	
	 if (ain.isValid()) {
		 /////////////qDebug() << "### indice  " << ain.data(Qt::UserRole).toString();
			oggettoID = ain.data(Qt::UserRole).toUInt();
    }

		QMenu *TContext = new QMenu();
		TContext->addAction(QIcon(QString::fromUtf8(":/default/img/default/reload.png")), tr( "Carica e Ricarica" ), this , SLOT( init() ) );
		///////TContext->addAction(QIcon(QString::fromUtf8(":/img/reload.png")),tr( "Ricarica tabella dal server" ), this , SLOT( reinit() ) );
	  ///////TContext->addSeparator();
	  TContext->addAction(QIcon(QString::fromUtf8(":/default/img/default/File_up.png")),tr( "Invia al server" ), this , SLOT( SendonServer() ) );
	  //////TContext->addSeparator();
		   if (oggettoID > 0) {
				   TContext->addSeparator();
		       QAction *actionopenweb0 = new QAction(tr("Mostra locale ID %1").arg(oggettoID),this);
				   actionopenweb0->setIcon(QIcon(QString::fromUtf8(":/default/img/default/oggetto.png")));
				   actionopenweb0->setData(oggettoID);
				   connect(actionopenweb0, SIGNAL(triggered()), this,  SLOT(OpenLocal()));
				 
				   QAction *actionopenweb = new QAction(tr("Mostra web ID %1").arg(oggettoID),this);
				   actionopenweb->setIcon(QIcon(QString::fromUtf8(":/img/web-48x48.png")));
				   actionopenweb->setData(oggettoID);
				   connect(actionopenweb, SIGNAL(triggered()), this,  SLOT(OpenWeb()));
				 
				   QAction *actionopenweb1 = new QAction(tr("Mostra cartella dati web ID %1").arg(oggettoID),this);
				   actionopenweb1->setIcon(sysicon.icon(QFileIconProvider::Folder));
				   actionopenweb1->setData(oggettoID);
				   connect(actionopenweb1, SIGNAL(triggered()), this,  SLOT(OpenWebPath()));
				 
				 
				 
				   TContext->addAction(actionopenweb0);
				   TContext->addAction(actionopenweb);
				   TContext->addAction(actionopenweb1);
				   TContext->addSeparator();
			 }
	  TContext->exec(QCursor::pos());
    TContext->deleteLater();
    delete TContext;
	
}




void WebCateList::OpenWeb()
{
	  QAction *textAction = qobject_cast<QAction *>(sender());
    const int idx = textAction->data().toInt();
	  qDebug() << "### OpenWeb  " << idx;
	  if (setter.value("pm/host").toString().size() > 0) {
		         QUrl web(decodeBase64(setter.value("pm/host").toString())); 
			       QString urlcomplete = QString("http://%1/lodging/it/%2/index.html").arg(web.host()).arg(idx);
			       OpenDesk( QUrl(urlcomplete) );
		} else {
			QMessageBox::warning(0, tr("Errore!"),tr("Configurazione del web mancante!\nAprite la configurazione ed inserite il host destinatario."));
		}
	
}

void WebCateList::OpenWebPath()
{
	  QAction *textAction = qobject_cast<QAction *>(sender());
    const int idx = textAction->data().toInt();
	  qDebug() << "### OpenWeb  " << idx;
	  if (setter.value("pm/host").toString().size() > 0) {
		         QUrl web(decodeBase64(setter.value("pm/host").toString())); 
			       QString urlcomplete = QString("http://%1/data/1000/%2/").arg(web.host()).arg(idx);
			       OpenDesk( QUrl(urlcomplete) );
		} else {
			QMessageBox::warning(0, tr("Errore!"),tr("Configurazione del web mancante!\nAprite la configurazione ed inserite il host destinatario."));
		}
	
}



////////////////http://c4.ppk.go/data/1000/96/

void WebCateList::OpenLocal()
{
	qDebug() << "### OpenLocal  ";
	  QAction *textAction = qobject_cast<QAction *>(sender());
    const uint idx = textAction->data().toUInt();
	  emit OpenLocalItem(idx);
}

void WebCateList::SendonServer()
{
	qDebug() << "### SendonServer  ";
}



void WebCateList::init()
{
	QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
  UPDA_regione.clear();
	QString oggetti_c = "SELECT ID,CID,CID_4 AS CITY,TIPO_1 AS TYPE,NOME_2 AS NAME,DIR_6 AS DIR "
	                  "from APPCASE WHERE DIR_6 !='' AND TIPO_1 < 100 AND "
	                   "( CID_4  IN ( SELECT DISTINCT id FROM `LUOGHI` WHERE cpa >0 )) order by NOME_2";
	QString tipe_c = "SELECT *FROM TIPO_OGGETTI ORDER BY POS";
	c_model = new QSqlQueryModel();
	c_model->setQuery(oggetti_c,db->current());
	t_model = new QSqlQueryModel();
	t_model->setQuery(tipe_c,db->current());
	ReadModel = new QSqlQueryModel();
  ReadModel->setQuery(RICHIESTA_PAESI,db->current());
	model = new QStandardItemModel();
	model->setHorizontalHeaderItem(0,new QStandardItem(tr("Id")));
	model->setHorizontalHeaderItem(1,new QStandardItem(tr("Nome")));
	menu.clear();
	bases.clear();
	topul.clear();
	
	for (int i = 0; i < Small_Language.size(); ++i)  {
				const QString name = Small_Language.at(i);
		            QDomDocument dd;
	              QDomElement iroot = dd.createElement("house_menu");
				        dd.appendChild( iroot );
				        QDomElement root = dd.createElement("div");
				        root.setAttribute ("id","TreeHouses");
		            root.setAttribute ("class","mlmenu vertical blindv blackwhite delay inaccesible");
				        root.setAttribute ("xmlns","http://www.w3.org/1999/xhtml");
		            iroot.appendChild( root );
		            bases.insert(name,root);
		            menu.insert(name,dd);
	}
	for (int i = 0; i < t_model->rowCount(); ++i) {
		     QSqlRecord rt = t_model->record(i);
		     if (Disponi(rt.value("ID").toInt())) {
		       model->invisibleRootItem()->appendRow(Compose_Type(i));
				 }
	}
	
	
	
	
	for (int i = 0; i < Small_Language.size(); ++i)  {
		      const QString name = Small_Language.at(i);
		      QString filename = QString("house_menu_%1").arg(name);
		      QString stream = encodeBase64(menu[name].toString(1));
					QString newfile = QString("REPLACE INTO HFILE VALUES ('%1', 'xml','%2',NOW())").arg(filename).arg(stream);
					db->UpDateQuery(newfile);
					/////////fwriteutf8(filename,menu[name].toString(1));
	}
	
	for (int i = 0; i < UPDA_regione.size(); ++i)  {
	db->UpDateQuery(UPDA_regione.at(i));
	}
	
	///////connect(this, SIGNAL(clicked(QModelIndex) ), this , SLOT(expand(QModelIndex) ));
	
	setModel(model);
	setEditTriggers(QAbstractItemView::NoEditTriggers);
	setSortingEnabled(false);
	setSelectionBehavior(QAbstractItemView::SelectRows);
	////////////expandAll();
	resizeColumnToContents(0);
	QApplication::restoreOverrideCursor();
}

void WebCateList::ActiveTre( QModelIndex index )
{
    if (!index.isValid()) {
    return;
    }
		if (isExpanded(index)) {
			collapse(index);
		} else {
			expand(index);
		}
}



bool WebCateList::Disponi2( int tipo , int paese )
{
	 for (int i = 0; i < c_model->rowCount(); ++i) {
						QSqlRecord rc = c_model->record(i);
						if (rc.value("TYPE").toInt() == tipo && rc.value("CITY").toInt() == paese) {
							return true;
						}
	 }
	return false;
}
bool WebCateList::Disponi( int tipo )
{
	 for (int i = 0; i < c_model->rowCount(); ++i) {
						QSqlRecord rc = c_model->record(i);
						if (rc.value("TYPE").toInt() == tipo) {
							return true;
						}
	 }
	return false;
}
/* torna case oggetti */
void WebCateList::Case( int tipo , int paese , QStandardItem *parent , const int regione )
{
	 for (int i = 0; i < c_model->rowCount(); ++i) {
														QSqlRecord rc = c_model->record(i);
												    if (rc.value("TYPE").toInt() == tipo && rc.value("CITY").toInt() == paese) {
															  QList<QStandardItem *> Pack;
												        QStandardItem *item_a = new QStandardItem(rc.value("ID").toString());
	                              item_a->setFlags ( Qt::ItemIsEnabled );
										            item_a->setData(rc.value("ID").toInt(),Qt::UserRole);
															
                                const QString Stxt =	QString("UPDATE %1 SET REG=%2 WHERE ID=%3 LIMIT 1 ").arg(TABELLA_CASE).arg(regione).arg(rc.value("ID").toString());
												        UPDA_regione.append(Stxt);
												        QStandardItem *item_b = new QStandardItem(rc.value("NAME").toString() + " /" +rc.value("DIR").toString());
	                              item_b->setFlags ( Qt::ItemIsEnabled );
										            item_b->setData(rc.value("ID").toInt(),Qt::UserRole);
															  item_b->setData(QIcon(QString::fromUtf8(":/default/img/default/gohome.png")),Qt::DecorationRole);
															  Pack.append(item_a);
										            Pack.append(item_b);      ////////////NAME,DIR_6
															  parent->appendRow(Pack);
														}
		}
}

void WebCateList::NomiPaesi( QStandardItem *parent , int tipo , int madre , QMap<QString,QDomElement> append )
{
	
	///////////qDebug() << "### a  #################################";
	bool take = false;
	QFileIconProvider  sysicon;
	int starter = 0;
	
	
		
		                                   
																				   
																				 
		
	
		
		
		
	
	for (int i = 0; i < ReadModel->rowCount(); ++i) {
		     QSqlRecord rp = ReadModel->record(i);
		     const int level =  rp.value("level").toInt();
		     const int city_id = rp.value("id").toInt();
		     QString correntN = rp.value("name").toString();
		     if (level == 2 && city_id == madre) {
					 take = true;
				 }
				 
				 
		    ////////////// qDebug() << "### NomiPaesi  " << city_id << take << level << correntN;
				 
		     if (level == 3 && take ) {
											 bool maket = Disponi2(tipo,city_id);
					             if (maket) {
												 
												 
												                
					 
					 
					 		                           QList<QStandardItem *> Pack;
												                 QStandardItem *item_a = new QStandardItem(rp.value("id").toString());
	                                       item_a->setFlags ( Qt::ItemIsEnabled );
										                     item_a->setData(QString("p%1").arg(city_id),Qt::UserRole);
																				 
					 
					 	                             for (int i = 0; i < Small_Language.size(); ++i)  {
																				   const QString name = Small_Language.at(i);
																						 
																				 QDomElement downli = menu[name].createElement("li");
								                         QDomElement downlink = menu[name].createElement("a");
								                         downlink.setAttribute("title",correntN);
																				 downlink.setAttribute("href",QString("/finder/%3/pagesearch/?ho=&c=%1&t=%2").arg(city_id).arg(tipo).arg(name));
																				 downlink.appendChild(menu[name].createTextNode(correntN));
																				 downli.appendChild(downlink);
																				 append[name].appendChild(downli);
																				 /////////downli.appendChild(topul2[name]);      
																				  
																						 
																					 }
					 
																				 
															
												
												                 QStandardItem *item_b = new QStandardItem(correntN);
	                                       item_b->setFlags ( Qt::ItemIsEnabled );
										                     item_b->setData(QString("p%1").arg(city_id),Qt::UserRole);
																				 item_b->setData(sysicon.icon(QFileIconProvider::Folder),Qt::DecorationRole);
															           Pack.append(item_a);
										                     Pack.append(item_b);      ////////////NAME,DIR_6
															           parent->appendRow(Pack);
												                 Case(tipo,city_id,item_a,madre);
											 }
					 
				 }
		
		     
		
				  if (take && level == 2 && city_id != madre) {
						/* stop*/
						take = false;
					}
		
		
	}
	
	////////////qDebug() << "### b  #################################";
}



QList<QStandardItem *> WebCateList::Compose_Type( int rowposition )
{
	  QFileIconProvider  sysicon;
	  QMap<QString,QDomElement> nextul;
    QSqlRecord r = t_model->record(rowposition);
	  const int Pid = r.value("ID").toInt();
    QString lait = r.value("NAME_IT").toString();
	  QList<QStandardItem *> diritto;
	  QFont bold_base_font = qApp->font();
    bold_base_font.setBold ( true );
	
	  ///////////  bool WebCateList::Disponi( int tipo )
	  
	  for (int i = 0; i < Small_Language.size(); ++i)  {
				const QString name = Small_Language.at(i);
			  QString tagname = QString("name_%1").arg(Small_Language.at(i));
        QDomElement htmul = menu[name].createElement("ul");
			  
				QDomElement htmh2 = menu[name].createElement("a");
				htmh2.setAttribute("class","HouseTree");
			  htmh2.setAttribute("title",r.value(tagname.toUpper()).toString());
				htmh2.appendChild(menu[name].createTextNode(r.value(tagname.toUpper()).toString()));
			  htmh2.setAttribute("href",QString("/finder/%2/pagesearch/?ho=&r=&t=%1").arg(Pid).arg(name));
			
			  QDomElement htmli = menu[name].createElement("li");
			  /* append first */
			  htmul.appendChild(htmli);
			  htmli.appendChild(htmh2);
			  bases[name].appendChild(htmul);
			  /* append first */
			  
			  QDomElement uldown = menu[name].createElement("ul");
				htmli.appendChild(uldown);
			  topul.insert(name,uldown);
   }
	 
	 
	 
	                  
								    //////////lastul.insert(name,uldown);
	
	
										/* tipo */
	                  QStandardItem *item_0 = new QStandardItem(r.value("ID").toString());
	                  item_0->setFlags ( Qt::ItemIsEnabled );
										item_0->setData(QString("t%1").arg(rowposition),Qt::UserRole);
	                  QStandardItem *item = new QStandardItem(lait);
                    item->setFlags ( Qt::ItemIsEnabled );
			              item->setData(QString("t%1").arg(rowposition),Qt::UserRole);
	                  item->setData(bold_base_font,Qt::FontRole);
										item->setData(sysicon.icon(QFileIconProvider::Folder),Qt::DecorationRole);
	                  /* tipo */
	
	                  for (int i = 0; i < ReadModel->rowCount(); ++i) {
		                            QSqlRecord rp = ReadModel->record(i);
															  const int level =  rp.value("level").toInt();
																const int city_id = rp.value("id").toInt();
		                            if (level == 2) {
																	    //////////if (Disponi2(Pid,city_id))  {
																				 QList<QStandardItem *> Pack;
												                 QStandardItem *item_a = new QStandardItem(rp.value("id").toString());
	                                       item_a->setFlags ( Qt::ItemIsEnabled );
										                     item_a->setData(QString("r%1").arg(city_id),Qt::UserRole);
																	
																				 
																	       nextul.clear();
																	       for (int i = 0; i < Small_Language.size(); ++i)  {
																	         const QString name = Small_Language.at(i);
																					 QDomElement uldown = menu[name].createElement("ul");
																					 nextul.insert(name,uldown);
																				 }
																	       
																	       
																	
																	       NomiPaesi(item_a,Pid,city_id,nextul);
																	
																	
																				 /////////////Case(Pid,city_id,item_a);
																				 QString correntN = rp.value("name").toString();
															
												
												                 QStandardItem *item_b = new QStandardItem(correntN);
	                                       item_b->setFlags ( Qt::ItemIsEnabled );
										                     item_b->setData(QString("r%1").arg(city_id),Qt::UserRole);
																				 item_b->setData(sysicon.icon(QFileIconProvider::Folder),Qt::DecorationRole);
															           Pack.append(item_a);
										                     Pack.append(item_b);      ////////////NAME,DIR_6
																	
																	       if (item_a->hasChildren()) {
															           item_0->appendRow(Pack);
																					 
																					 for (int i = 0; i < Small_Language.size(); ++i)  {
																				   const QString name = Small_Language.at(i);
																						 
																				 QDomElement downli = menu[name].createElement("li");
								                         QDomElement downlink = menu[name].createElement("a");
								                         downlink.setAttribute("title",correntN);
																				 downlink.setAttribute("href",QString("/finder/%3/pagesearch/?ho=&r=%1&t=%2").arg(city_id).arg(Pid).arg(name));
																				 downlink.appendChild(menu[name].createTextNode(correntN));
																				 downli.appendChild(downlink);
																				 topul[name].appendChild(downli);
																				 downli.appendChild(nextul[name]);      
																				  
																						 
																					 }
																					 
																					 
																					 
																				 } else {
																					 Pack.clear();
																				 }
																				
																			//////////}
		                             
						                    }
	                    }
			              
									
	
	
	
	
	                  diritto.append(item_0);
										diritto.append(item);
	  
	
	return diritto;
	
}














FirstMain::FirstMain( QWidget* parent )
	: QMainWindow( parent )
{
	QDesktopWidget *desk = QApplication::desktop();
	LoadDBS = false;
	 winsize = desk->screenGeometry();
	Info_Menu = Controller();
	Info_Menu->setWindowFlags(Qt::Tool);
	Info_Menu->setWindowTitle(tr("Oggetti disponibili. CTRL+X"));
		QPoint pos;
        pos.setX((winsize.width() / 2) - (Info_Menu->width() / 2));
        pos.setY((winsize.height() / 2) - (Info_Menu->height() / 2));
	Info_Menu->move(pos);
	Info_Menu->hide();
	
	  
    

	
	
}
void FirstMain::Setdb( DB_Manager *dbin ) 
{
	db = dbin;
	db->GrepOrfani();
	db->FillBoxTipo(box_panel,0,1);
	db->FillBoxLuoghi(box_panel_1,0,1);
	box_panel->setCurrentIndex(0);
	box_panel_1->setCurrentIndex(0);
	LoadDBS = true;
	MenuControllerSwaper();
	connect(box_panel, SIGNAL(currentIndexChanged(int)), this, SLOT(MenuControllerSwaper()));
	connect(box_panel_1, SIGNAL(currentIndexChanged(int)), this, SLOT(MenuControllerSwaper()));
	webtree->SetDb(dbin);
}


/*
SELECT * FROM
( SELECT * FROM `APPCASE`
WHERE ( APPCASE.CID_4 IN ( SELECT DISTINCT id FROM `LUOGHI` WHERE cpa >0) )
}

SELECT DISTINCT id FROM `LUOGHI` WHERE cpa >0

*/


void FirstMain::MenuControllerSwaper()
{
	if (!LoadDBS) {
	return;
	}
	if (!db->current().isOpen()) {
		return;
	}
	LoadDBS = false;
	int tipoattivo = box_panel->itemData(box_panel->currentIndex()).toInt();
	int luogo = box_panel_1->itemData(box_panel_1->currentIndex()).toInt();
	
	QString Tipos = QString("%1").arg(tipoattivo);
	QString Luogos = QString("%1").arg(luogo);
	QString querypanel;
	
		QString WWEE;
		if (tipoattivo > 0 && luogo > 0) {
		  WWEE = "CID_4="+Luogos+" AND TIPO_1="+Tipos+" AND ";
		}
		if (tipoattivo > 0 && luogo == 0) {
		  WWEE = "TIPO_1="+Tipos+" AND ";
		}
		if (tipoattivo == 0 && luogo > 0) {
		  WWEE = "CID_4="+Luogos+" AND ";
		}
		
	querypanel = "SELECT APPCASE.ID AS Nr, TAX_01 AS Liv, SHOW_CAL AS Cal,TID AS Ti, NOME_2 AS Nome,"
                     " DIR_6 AS Direzione, LUOGHI.name AS Luogo," 
                     " TEL_7 AS Tel FROM APPCASE,LUOGHI WHERE "+WWEE+" "
                     "LUOGHI.id = APPCASE.CID_4 "
                     " ORDER BY NOME_2";
	if (luogo == 40004)  {
		querypanel 	= "SELECT APPCASE.ID AS Nr, TAX_01 AS Liv, SHOW_CAL AS Cal,TID AS Ti, NOME_2 AS Nome,"
                     " DIR_6 AS Direzione, CID_4 AS Luogo, " 
                     " TEL_7 AS Tel FROM APPCASE WHERE "
                     "( APPCASE.CID_4 NOT IN ( SELECT DISTINCT id FROM `LUOGHI` WHERE cpa >0 )) "
                     " ORDER BY NOME_2";
	}
	if (tipoattivo == 104) {
		querypanel = "SELECT APPCASE.ID AS Nr, TAX_01 AS Liv, SHOW_CAL AS Cal,TID AS Ti, NOME_2 AS Nome,"
                     " DIR_6 AS Direzione, CID_4 AS Luogo," 
                     " TEL_7 AS Tel FROM APPCASE WHERE TIPO_1=104 "
                     " ORDER BY NOME_2";
	}
	
	
	
	
	
	Model_Menu = new QSqlQueryModel();
  Model_Menu->setQuery(querypanel,db->current());
	listaoggetti->setModel(Model_Menu);
	listaoggetti->setAlternatingRowColors(true);
	listaoggetti->resizeColumnsToContents();
	listaoggetti->resizeRowsToContents();
	listaoggetti->setEditTriggers(QAbstractItemView::NoEditTriggers);
  listaoggetti->setSortingEnabled(false);
  listaoggetti->setSelectionBehavior(QAbstractItemView::SelectRows);
	LoadDBS = true;
}



/*
void FirstMain::on_paesi_currentIndexChanged()
{
	if (!db->current().isOpen()) {
		return;
	}
	int tipoattivo = box_panel_1->itemData(box_panel_1->currentIndex()).toInt();
	QString Tipos = QString("%1").arg(tipoattivo);  
	QString querypanel = "SELECT APPCASE.ID AS Nr,NOME_2 AS Nome,"
                     " DIR_6 AS Direzione, LUOGHI.name AS Luogo," 
                     " TEL_7 AS Tel FROM APPCASE,LUOGHI WHERE CID_4="+Tipos+" AND "
                     "LUOGHI.id = APPCASE.CID_4 "
                     " ORDER BY NOME_2";
	Model_Menu = new QSqlQueryModel();
  Model_Menu->setQuery(querypanel,db->current());
	listaoggetti->setModel(Model_Menu);
	listaoggetti->setAlternatingRowColors(true);
	listaoggetti->resizeColumnsToContents();
	listaoggetti->resizeRowsToContents();
	listaoggetti->setEditTriggers(QAbstractItemView::NoEditTriggers);
  listaoggetti->setSortingEnabled(false);
  listaoggetti->setSelectionBehavior(QAbstractItemView::SelectRows);
}

	*/



QWidget *FirstMain::Controller()
{
	
	Poppi = new QWidget();
	Poppi->setWindowTitle(tr("Oggetti disponibili."));
	Poppi->setMaximumWidth(1000);
	Poppi->setMinimumWidth(420);
	Poppi->setMinimumHeight(530);
	
	gridLayout_0 = new QGridLayout(Poppi);
	tabmenu = new QTabWidget(Poppi);
	gridLayout_0->addWidget(tabmenu, 0, 0, 1, 1);
	
	QString msgDB =tr("<p>Creazione listato web:</p>");
	msgDB.append("<p><b>I criteri per web sono: </b></p>");
	msgDB.append("<ul>");
	msgDB.append("<li>1 - Cpa paese maggiore di 0</li>");
	msgDB.append("<li>2 - ID tipo oggetto minore di 100</li>");
	//////msgDB.append("<li>3 - Nome proprietario, direzione o gerente presente</li>");
	msgDB.append("<li>4 - minimo un Telefono presente</li>");
	msgDB.append("</ul>");
	msgDB.append("<p>Tasto destro per aggiornare.</p>");
	
	
	
  /*  gui web */
	Pwebbi = new QWidget();
	gridLayout_1 = new QGridLayout(Pwebbi);
	webtree = new WebCateList(Pwebbi);
	QLabel *desclabel = new QLabel(msgDB,Pwebbi);
	gridLayout_1->addWidget(desclabel, 0, 0, 1, 1);
	gridLayout_1->addWidget(webtree, 1, 0, 1, 1);
	/*  gui web */
	
	
	
	
	
	
	Panel = new QWidget(Poppi);
	
	gridLayout = new QGridLayout(Panel);
	hboxLayout = new QHBoxLayout();
	label_panel = new QLabel(Panel);
	box_panel = new QComboBox(Panel);
	label_panel->setText ( tr("Tipo oggetto:") );
	
	
/////////////////connect(box_panel, SIGNAL(currentIndexChanged(int)), this, SLOT(on_box_panel_currentIndexChanged()));
	
	hboxLayout->addWidget(label_panel);
	hboxLayout->addItem(new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum));
	hboxLayout->addWidget(box_panel);
	/* append steuerung */
	
	
	hboxLayout_1 = new QHBoxLayout();
	label_panel_1 = new QLabel(tr("Luoghi"),Panel);
	box_panel_1 = new QComboBox(Panel);
	hboxLayout_1->addWidget(label_panel_1);
	hboxLayout_1->addItem(new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum));
	hboxLayout_1->addWidget(box_panel_1);
	
////////////////////connect(box_panel_1, SIGNAL(currentIndexChanged(int)), this, SLOT(on_paesi_currentIndexChanged()));
	
	gridLayout->addLayout(hboxLayout, 0, 0, 1, 1);
	gridLayout->addLayout(hboxLayout_1, 1, 0, 1, 1);
	listaoggetti = new QTableView(Panel);
	gridLayout->addWidget(listaoggetti, 2, 0, 1, 1);
	
	tabmenu->addTab(Panel,QIcon(QString::fromUtf8(":/default/img/default/oggetto.png")),tr("Oggetti disponibili"));
	tabmenu->addTab(Pwebbi,QIcon(QString::fromUtf8(":/img/web-48x48.png")),tr("Oggetti per Web"));
	
	
  tabmenu->setCurrentIndex (0);
	
	return Poppi;
}


    















